#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "configuredialog.h"
#include "ai_instant.h"
#include "selecttime.h"


#include <QDebug>
#include <QSqlQuery>
#include <QMessageBox>

int trainTime;

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("my.db");
    if(db.open())
        qDebug()<<"打开成功！";
    QSqlQuery query;
    if(query.exec("create table patient("
                  "ID VARCHAR(255),"
                  "NAME VARCHAR(30),"
                  "GENGER VARCHAR(30),"
                  "GOOD VARCHAR(30),"
                  "BAD VARCHAR(30),"
                  "JOB VARCHAR(30),"
                  "CHECKTIMES VARCHAR(30),"
                  "BIRTHDAY VARCHAR(30),"
                  "DAMAGEDAY VARCHAR(30),"
                  "SURGERYDAY VARCHAR(30),"
                  "ASSEESSDAY VARCHAR(30),"
                  "DOCTOR VARCHAR(30),"
                  "DIAGNOSE VARCHAR(255),"
                  "HISTORY VARCHAR(255))"))
        qDebug()<<"创建成功！";
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_btn_press_clicked()
{
    //创造InstantAiCtrl对象
    InstantAiCtrl *instantAiCtrl = InstantAiCtrl::Create();

    //获取可用设备列表
    Array<DeviceTreeNode> *supportedDevices = instantAiCtrl->getSupportedDevices();

    //若无可用设备，发出警告
    if (supportedDevices->getCount() == 1)
        QMessageBox::warning(this, tr("警告"),tr("   未检测到设备！\n请检查设备连接状态"),tr("确定"));
    else{
        instantAiCtrl->Dispose();
        supportedDevices->Dispose();
        SelectTime *selectTime = new SelectTime;
        selectTime->show();
    }
}

void MainWindow::on_breakingGame_toolButton_clicked()
{
    QProcess *pro = new QProcess;
    pro->start("D:/b/Game_BreakingBricks3.exe");
}

void MainWindow::on_footballGame_toolButton_clicked()
{
    QProcess *pro = new QProcess;
    pro->start("D:/d/Game_BallRoll.exe");
}

void MainWindow::on_mazeGame_toolButton_clicked()
{
    QProcess *pro = new QProcess;
    pro->start("D:/c/Game_BalanceCampass.exe");
}

void MainWindow::on_btn_file_clicked()
{
    patientFile = new PatientFile;
    patientFile->show();
}
